package com.epalmpay.controller.channel.agent;

import com.epalmpay.commom.BaseController;
import com.epalmpay.dto.agent.AgentInfoInDTO;
import com.epalmpay.dto.agent.AgentInfoOutDTO;
import com.epalmpay.dto.agent.AgentNetInDTO;
import com.epalmpay.dto.system.BaseOutDTO;
import com.epalmpay.dto.system.ShopInDTO;
import com.epalmpay.dto.system.ShopOutDTO;
import com.epalmpay.exception.ApplicationException;
import com.epalmpay.service.agent.IAgentService;
import com.epalmpay.service.shop.IShopService;
import com.epalmpay.status.Rescode;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * Created by Administrator on 2018/1/3.
 */
@Controller
@RequestMapping(value="/merchant/agentNetIn")
public class AgentNetInController extends BaseController {


    @Resource
    private IShopService shopService;

    @RequestMapping(value="/saveAgentNetIn")
    @ResponseBody
    public ShopOutDTO saveAgentNetIn(@RequestBody AgentNetInDTO agentNetInDTO){
        ShopOutDTO shopOutDTO = new ShopOutDTO();
        Boolean flag;
        try {
            flag=shopService.saveAgentNetIn(agentNetInDTO);
            if(flag){
                shopOutDTO.setErrorCode(Rescode.SUCCESS, "处理成功");
            }else{
                shopOutDTO.setErrorCode(Rescode.DEFAULT_PREFIX, "处理出现异常");
            }
            return shopOutDTO;
        } catch (ApplicationException ae) {
            shopOutDTO.setErrorCode(ae.errCode, ae.errMsg);
            ae.printStackTrace();
        }catch (Exception e) {
            shopOutDTO.setErrorCode(Rescode.DEFAULT_PREFIX, "处理出现异常");
            e.printStackTrace();
        }
        return shopOutDTO;
    }



}
